package com.example.service;

import com.example.common.Result;
import com.example.dao.UserDao;
import com.example.entity.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserService {

    @Resource
    private UserDao userDao;

    public Result login(String username , String password){
        User user = userDao.findByName(username);
        if(user.getPassword().equals(password)){
            return Result.success();
        }else {
            return Result.error("1","用户名或密码错误");
        }
    }

    public Result register(User user){
        return Result.success(userDao.save(user));
    }

}
